#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <stack>

using namespace std;

bool Func(string& s)
{
	stack<char> st;
	for (auto ch : s)
	{
		if (ch == '(' || ch == '[' || ch == '{')
		{
			st.push(ch);
		}
		else
		{
			if (st.empty())
				return false;

			char top = st.top();
			st.pop();
			if (ch == ')' && top != '(')
				return false;
			if (ch == ']' && top != '[')
				return false;
			if (ch == '}' && top != '{')
				return false;
		}
	}
	return st.empty();
}

int main()
{
	string str;
	while (cin >> str)
	{
		bool ret = Func(str);
		cout << ret << endl;
	}

	return 0;
}